<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of CrearSolicitud
 *
 * @export Modules
 */
class CrearSolicitud extends Module {

    private $Solicitud;

    public function getSolicitud() {
        if (!$this->Solicitud) {
            Loader::using("models::entities::Solicitudes");
            $this->Solicitud = new Solicitudes();
        }
        return $this->Solicitud;
    }

    public function index() {
        $Empresas = $this->model->companies->GetAll();
        $PlanesEstudios = $this->model->career->GetByTipoPrograma(PlanesEstudios::PREGRADO, false);
        $Paises = $this->model->countries->GetAll(false);

        $this->assign("companies", $Empresas);
        $this->assign("careers", $PlanesEstudios);
        $this->assign("countries", $Paises);
        $this->assign("action", $this->route->action("Create"));
        $this->assign("GetDepartamentos", $this->route->moduleAction("PublicData", "GetDepartamentoByPais", array("ajax" => "true", "IdPais" => ""))
        );

        $this->assign("GetMunicipios", $this->route->moduleAction("PublicData", "GetMunicipio", array("ajax" => "true", "CodigoDepartamento" => ""))
        );

        $this->display("index");
    }

    /**
     * @export-metadata Bind:this.Solicitud
     */
    public function Create() {
        if ($this->request->submitted()) {

            $this->Solicitud->setSolicitante(new Trabajadores());
            $this->Solicitud->setTutor(new Trabajadores());

            $this->model->applications->Create($Solicitud);

            $this->addMessage(new Message("", "Wiiiiii!", Message::SUCCESS));
            $this->display();
        } else {
            $this->index();
        }
    }

}

?>
